﻿
using CMS.Entities;
using CMS.Models;
using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CMS
{
    public class AppData : ObservableObject
    {

        public AppData()
        {
            roles.Add(new Role() { Name = "管理员", Id = 0 });
            roles.Add(new Role() { Name = "操作员", Id = 1 });
        }

        public static AppData Instance = new Lazy<AppData>(()=> new AppData()).Value;

        private string systemName = "仓库物资管理系统";

        public string SystemName
        {
            get { return systemName; }
            set { systemName = value; RaisePropertyChanged(); }
        }

        private Member member = new Member();

        public Member CurrentUser
        {
            get { return member; }
            set { member = value; RaisePropertyChanged("CurrentUser");  }
        }

        /// <summary>
        /// 主窗体
        /// </summary>
        public MainWindow MainWindow { get; set; } = null;

        /// <summary>
        /// 显示或隐藏遮罩层
        /// </summary>
        /// <param name="isMark"></param>
        public void ShowMarkLayer(bool isMark)
        {
            if(MainWindow == null) return;
            MainWindow.markLayer.Visibility = isMark ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
        }


        public List<Role> roles = new List<Role>();
        /// <summary>
        /// 角色集合
        /// </summary>
        public List<Role> Roles
        {
            get
            {
                return roles;
            }
            set
            {
                roles = value;
                RaisePropertyChanged();
            }
        }
    }
}
